Codes were written and run in STATA 12.1
Each dofile is documented so that the user can understand what each piece of code is doing.

*********************************************************************************************************
*                                       PART 1: EXECUTION                                               *
*********************************************************************************************************
Steps for replicating the results of Busso, DiNardo and McCrary (2013)

1) SIMULATIONS. To execute the simulations, run the following commands in the terminal:
   > chmod u=rwx SIMULATIONS
   > SIMULATIONS &
   (The last 3 arguments in each line of the file SIMULATIONS are the 
    the job/seed id, the number of reps of each job, and the type of dgp. 
    You can use these arguments to parallelize the simulations in as many jobs you want.
    Changing these numbers will change the seed and therefore the actual numerical results.)

4) TABLES & FIGURES. Once the simulations are done you should run the following three scripts:
   do compile.do
   do tables.do
   do figures.do

*********************************************************************************************************
*                              PART 2: MAIN SCRIPTS FOR SIMULATIONS                                     *
*********************************************************************************************************
Two main files to get the simulations:

simulation.do - > is the core program used to perform all the simulations. It takes 3 arguments
                  SEEDw hich should be an integer greater than 0.
                  REPS which should be an interger greater than 0
                  TYPE equal to {frolich, frolich001, frolich_est, frolich_est001, nsw, misspec}, 
                  
SIMULATIONS    -> runs the simulations in a unix terminal. You can manually run this in any machine
                  regardless of the OS through STATA's command line.

*********************************************************************************************************
*                     PART 3: MAIN SCRIPTS FOR TABLES & FIGURES                                         *
*********************************************************************************************************
Four main files to get the tables:

compile.do     -> Takes the simulations datasets and compile a big file with the results
                  for Frolich-based DGPs, NSW DGPs and misspecified estimators/DGP.

tables.do      -> Takes the simulations datasets and produces the paper's tables in excel.

figures.do     -> produces the paper's figures. Edits to the figures were done calling labels&lines.grec 
                 labels&lines_p2.grec, labels&line_fig1.grec, labels&line_fig2.grec, labels&line_fig3.grec

*********************************************************************************************************
*                           PART 4: ESTIMATION AND SIMULATION ADO FILES                                 *
*********************************************************************************************************
The following files are called by the main files that get simulations, tables and figures.

llrmatch.ado  -> computes local linear matching (using cross-validation)
mmatch.ado    -> computes all the other matching estimators (written by Abadie and Imbens (2002). Downloaded from 
                 http://www.economics.harvard.edu/faculty/imbens/software_imbens)
ipw.ado       -> estimates normalized and unnormalized reweighting
gpe.ado       -> estimates GPE reweighting

frolichdgp.ado     -> produces a dataset with frolich DGP (using a Fourier Series approximation)
frolichdgporig.ado -> produces a dataset with frolich DGP (using the original RESTAT 2004 version)
nsw.ado            -> produces a dataset with the NSW DGP
msdgp.ado          -> produces a dataset that allows for misspecification of the estimators

